package com.liit.util;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.liit.exception.WeixinException;

import name.zbq.bush.utils.StringUtil;

public class AssertHelper {

	/**
	 * 非空
	 * 
	 * @param obj
	 *            Map/Collectioin/String
	 * @param info
	 */
	public static void notEmpty(Object obj, String info) {
		if (obj == null)
			throw new WeixinException(info);
		if (obj instanceof Collection) {
			notEmpty((Collection) obj, info);
		} else if (obj instanceof String) {
			notEmpty(obj.toString(), info);
		} else if (obj instanceof Map) {
			notEmpty((Map) obj, info);
		}
	}

	private static void notEmpty(String str, String info) {
		if (str == null || str.trim().equals("")) {
			throw new WeixinException(info);
		}
	}

	private static void notEmpty(Collection coll, String info) {
		if (coll == null || coll.isEmpty()) {
			throw new WeixinException(info);
		}
	}

	private static void notEmpty(Map map, String info) {
		if (map == null || map.isEmpty()) {
			throw new WeixinException(info);
		}
	}

	/**
	 * 必须为空 否则throw exception
	 * 
	 * @param obj
	 * @param info
	 */
	public static void empty(Object obj, String info) {
		if (obj != null) {
			throw new WeixinException(info);
		}
	}
}
